model = RNN(vocab_size=vocab_size,
              hidden_dim=hidden_dim,
             num_layers=num_layers,
             embedding_dim=embedding_dim,
             output_dim=output_dim)
model.load_state_dict(torch.load("./best_model.pt"))
model.eval() # 开启预测模式
epoch_acc_count = 0 # 每个epoch训练的样本数
x_input = x_test.long().transpose(1, 0).contiguous()
x_input = x_input.to(device)
output_ = model(x_input) # torch.Size([6000, 2])
y_pred = torch.argmax(output_,dim=-1,keepdim=True) 
# y_pred:[6000, 1]
epoch_acc_count += (output_.argmax(axis=1) == y_test.view(-1)).sum()
acc_mean = epoch_acc_count / len(x_test)
print(acc_mean)  
